unit UframeBDEObjects;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes,
  Graphics, Controls, Forms, DB, DBTables,
  Dialogs, UframeDataBaseObjects, Menus, ComCtrls, ImgList;

type
  TframeBDEObjects = class(TframeDataBaseObjects)
  private
    FAliasName: String;
    procedure SetAliasName(const Value: String);
    procedure addFields(treeNode : TTreeNode; tableName : String);
  public
    { Public declarations }
    function getTableNameList : TStringList;
  published
    property AliasName : String read FAliasName write SetAliasName;
  end;

var
  frameBDEObjects: TframeBDEObjects;

implementation

{$R *.dfm}

{ TframeBDEObjects }

procedure TframeBDEObjects.addFields(treeNode: TTreeNode;
  tableName: String);
var list : TStringList;
    i : Integer;
    _Treenode : TTreeNode;
begin
  list := TStringList.Create;
  try
    Session.GetFieldNames(AliasName, tableName, list);
    for i := 0 to list.Count - 1 do
    begin
      _treeNode := TreeViewObjects.Items.AddChild(treeNode, list[i]);
      _treenode.ImageIndex := 2;
      _treenode.SelectedIndex := 2;
    end;
  finally
    FreeAndNil(list);
  end;//try
end;

function TframeBDEObjects.getTableNameList: TStringList;
var i : integer;
begin
  result := TStringList.Create();
  for i := 0 to TreeViewObjects.Items.Count - 1 do
  begin
    if TreeViewObjects.Items[i].Parent = nil then
      result.Add(TreeViewObjects.Items[i].Text);
  end;
end;

procedure TframeBDEObjects.SetAliasName(const Value: String);
var list : TStringList;
    i : Integer;
begin
  FAliasName := Value;
  list := TStringList.create();
  try
    Session.GetTableNames(value, '', false, false, list);
    TreeViewObjects.Items.Clear;
    for i := 0 to list.Count - 1 do
    begin
      addFields(
          TreeViewObjects.Items.Add(nil, list[i]),
          list[i]);
    end;//for
  finally
    FreeAndNil(list);
  end;//try
end;

end.
